package logic

import (
	"context"
	"renting-demo/model/mysql"

	"renting-demo/order_srv/internal/svc"
	"renting-demo/order_srv/order"

	"github.com/zeromicro/go-zero/core/logx"
)

type CompleteLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCompleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CompleteLogic {
	return &CompleteLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// todo: 完成订单
func (l *CompleteLogic) Complete(in *order.CompleteOrderReq) (*order.Response, error) {
	re := mysql.CompleteOrder(int(in.Orderid))
	if re == "0" {
		return &order.Response{
			Status: "0",
		}, nil
	}
	return &order.Response{
		Status: "1",
	}, nil
}
